import kuai

MSD_FILE = r"F:\Madlee\Job\TEAM\MayBridge\Optimize\sampleRHF.msd"
NAME_TAG = ">  <code> ("

def parse_name(block):
    i1 = block.find(NAME_TAG) + len(NAME_TAG)
    i2 = block.find(")", i1+1)
    return block[i1:i2].strip()


if __name__ == '__main__':
    # ff, eqt = kuai.read_ff(PPF_FILE)
    input = open(MSD_FILE)
    block = ""
    for i in input:
        block += i
        if i.startswith("$$$$"):
            mol1 = kuai.parse_mol(block, "msd")
            mol1.name = parse_name(block)
            print mol1.formula()
            keys = kuai.ForceField.list_keys(mol1, "AMBER")
            for i in keys:
                print i
            break
            block = ""
